﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!--自适应界面,如果出现,在某些设备出现界面偏小的话,检查一下有没有加入这句 -->
    <meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
    <link rel="stylesheet" href="../../../js/jqmobile/jquery.mobile-1.4.5.min.css" />
    <link href="../../../js/layer_mobile/need/layer.css" rel="stylesheet" />
    <!--<script src="../js/jquery.js"></script>-->
    <script src="../../../js/jquery.min2.1.4.js"></script>
    <script src="../../../js/jqmobile/jquery.mobile-1.4.5.min.js"></script>
    <script src="../../../js/cordova-1.5.0.js"></script>
    <script src="../../../js/layer_mobile/layer.js"></script>
    <script src="../../../js/jshelp.js"></script>
    <script type="text/javascript">
    /*
    *  TODO
     *  请在此处编写javascript代码
     */
checkCustomize = function(){

           var date = new Date();
           var year = date.getFullYear();
           var month = date.getMonth() + 1;
           var day = date.getDay();
           month = (month > 9) ? month : ("0" + month);
           day = (day < 10) ? ("0" + day) : day;
           var thisnm = year + "-" + month;//当前年份+月份
           var lastmonth= date.getMonth();
           lastmonth= (lastmonth> 9) ? lastmonth: ("0" + lastmonth);
           var lastnm= year + "-" + lastmonth;//当前年份+上次月份

           var thisbqcs=parseInt(jQuery("#field117").val());//根据当前人员获取当月补勤次数
           var lastbqcs=parseInt(jQuery("#field119").val());//根据当前人员获取上月补勤次数
           var tsry=jQuery("#field118").val(); //根据当前人员获取是否在特殊人员中
    if (tsry == "0") {
        var tbodyTrs = $("#oTable0> tbody >tr");//获取table
        var thiscount = 0;
        var lastcount = 0;
        var cccount = 0; //订货会出差和居家办公不计算
        for (var i = 0; i < tbodyTrs.length - 3; i++) {
            var bqlx_mx = jQuery('#field345_' + i).val(); //补勤类型0补勤1外勤2出差4订货会出差5居家办公
            var bqrq_mx = jQuery('#field113_' + i).val(); //补勤日期
            bqrq_mx = bqrq_mx.substring(0, 7);//截取补勤明细中的年月
            if (bqlx_mx == "0" || bqlx_mx == "1" || bqlx_mx == "2") {
                //如果补勤明细中的年月等于当年月，那么累计次数
                if (bqrq_mx == thisnm) {
                    thiscount++;
                }
                //如果补勤明细中的年月等于上月，那么累计次数
                else if (bqrq_mx == lastnm) {
                    lastcount++;
                }
            }
            //计算订货会出差、居家办公
            else {
                cccount++;
            }
        }
        //如果不都是订货会出差、居家办公要验证
        if (tbodyTrs.length - 3 != cccount) {
            //把以前补勤次数和本次补勤次数加在一起
            var allthiscount = parseInt(thisbqcs) + parseInt(thiscount);
            //把上月补勤次数和本次补勤次数加在一起
            var alllastcount = parseInt(lastbqcs) + parseInt(lastcount);
            //如果本次补勤中不含上月明细数据，那么不判断上月补勤次数
            if (allthiscount > 3 || alllastcount > 3) {
                alert("每月补勤次数不得超过3次！");
                return false;
            }
            else {
                return true;
            }

        }
    }
    else {
        return true;
    }

}
    </script>


    <script>
        //$(document).on("pagecreate", "#pageone", function () {
        //    $(document).on("scrollstart", function () {
        //        alert("开始滚动!");
        //    });
        //});
        //接受传参
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(decodeURI(r[2])); return null; //返回参数值
        }
        var customerCode = getUrlParam('customerCode');
        var mobile = getUrlParam('mobile');
        function tz(lx) {
            if (lx == "主页") {
                location.href = "..\\main.html?mobile=" + mobile + "&customerCode=" + customerCode;
            }
            else if (lx == "申请") {
                location.href = "sq_list.html?mobile=" + mobile + "&customerCode=" + customerCode;
            }
            else if (lx == "抢单") {
                location.href = "..\\TransferSnatch\\list.html?mobile=" + mobile + "&customerCode=" + customerCode;
            }
            else if (lx == "发货") {
                location.href = "..\\TransferDeliver\\list.html?mobile=" + mobile + "&customerCode=" + customerCode;
            }
            else if (lx == "配置") {
                location.href = "..\\Config\\list.html?mobile=" + mobile + "&customerCode=" + customerCode;
            }
        }
        function add(lx) {
            location.href = "sq_add.html?customerCode=" + customerCode + "&mobile=" + mobile;;
        }
    </script>
    <style>
        ul {
            list-style-type: none;
            padding: 0px;
            margin: 0px;
        }

            ul li {
                background-image: url(sqpurple.gif);
                background-repeat: no-repeat;
                background-position: 0px 5px;
                padding-left: 14px;
            }

        .tck {
            font: normal 12px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
            color: #4f6b72;
            background: #E6EAE9;
            padding: 20px;
        }
        /*按钮*/
        .btn {
            display: block;
            position: relative;
            background: #aaa;
            padding: 10px 20px 10px 20px;
            float: left;
            color: #fff;
            text-decoration: none;
            cursor: pointer;
            font-size: 13px;
            margin: 5px;
        }



        ul,
        li {
            list-style: none;
        }

        a {
            text-decoration: none;
        }

            a:hover {
                cursor: pointer;
                text-decoration: none;
            }

            a:link {
                text-decoration: none;
            }

        img {
            vertical-align: middle;
        }

        .ui-listview > p {
            white-space: normal;
        }
        /*店铺名称单号行*/
        div#findstorename.ui-grid-a .ui-block-a {
            width: 55%
        }

        div#findstorename.ui-grid-a .ui-block-b {
            width: 45%
        }
        /*联系人联系方式行*/
        div#findlxr.ui-grid-a .ui-block-a {
            width: 50%
        }

        div#findlxr.ui-grid-a .ui-block-b {
            width: 50%
        }
        /*发布数量调拨数量日期行*/
        div#findsl.ui-grid-a .ui-block-a {
            width: 30%
        }

        div#findsl.ui-grid-a .ui-block-b {
            width: 30%
        }

        div#findsl.ui-grid-a .ui-block-c {
            width: 40%
        }

        #controlgroupid .ui-controlgroup-controls {
            width: 100%;
        }

        #controlgroupid a {
            width: 25%;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <div data-role="page" id="pageone">
        <div data-role="header" data-position="fixed">
            <h1>申请列表</h1>
            <a href="#" class="ui-btn-left" data-rel="back">返回</a>
            <a onclick="add()" href="#" id="product_add" rel="external" class="ui-btn-right" data-transition="slide">新增</a>
        </div>
        <div data-role="content" id="main3Content">
            <ul id="thelist" data-role="listview" data-split-icon="gear" data-split-theme="d"
                data-filter="true" data-inset="true" data-filter-placeholder="全局搜索"></ul>
        </div>
        <div data-role="footer" data-position="fixed">
            <div data-role="navbar">
                <ul id="navbarlist">
                    <li><a href="#" onclick="tz('主页')" data-role="button" data-icon="home" data-iconpos="top">首页</a></li>
                    <li><a href="#" onclick="tz('申请')" data-role="button" data-icon="plus" data-iconpos="top">调拨申请</a></li>
                    <li><a href="#" onclick="tz('抢单')" data-role="button" data-icon="shop" data-iconpos="top">调拨抢单</a></li>
                    <li><a href="#" onclick="tz('发货')" data-role="button" data-icon="navigation" data-iconpos="top">调拨发货</a></li>
                    <li><a href="#" onclick="tz('配置')" data-role="button" data-icon="gear" data-iconpos="top">设置</a></li>
                </ul>
            </div>
        </div>
    </div>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script>
        //加载商品列表
        $(function () {
            if (mobile == "" || mobile == undefined || mobile == null) {
            } else {
                var loginLoadIndex = layer.load(2);
                $.ajax({
                    type: "get",
                    async: false,            //异步请求（同步请求将会锁住浏览器，用户其他操作必须等待请求完成才可以执行）
                    url: "ashx/list.ashx?type=get_request_list&customerCodes=" + customerCode + "&mobiles=" + mobile + "&a=" + Math.random(),
                    data: {},
                    dataType: "json",        //返回数据形式为json
                    success: function (data) {
                        var str = "";
                        if (data.item.length > 0) {
                            for (var i = 0; i < data.item.length; i++) {
                                str += '<li>';
                                str += '<div id="findstorename" class="ui-grid-a">';
                                str += '<div class="ui-block-a">';
                                str += '<h3> ' + data.item[i].username + '</h3>';
                                str += '</div>';
                                str += '<div class="ui-block-b">';
                                str += '<p>单号：' + data.item[i].docno + '</p>';
                                str += '</div>';
                                str += '</div>';
                                str += '<div class="ui-grid-a">';
                                str += '<p style="white-space:normal;">地址：' + data.item[i].takeaddress + '</p>';
                                str += '</div>';
                                str += '<div id="findlxr" class="ui-grid-a">';
                                str += '<div class="ui-block-a">';
                                str += '<p>联系人：' + data.item[i].takeman + '</p>';
                                str += '</div>';
                                str += '<div class="ui-block-b">';
                                str += '<p>联系方式：' + data.item[i].takephone + '</p>';
                                str += '</div>';
                                str += '</div>';
                                str += '<div id="findsl" class="ui-grid-a">';
                                str += '<div class="ui-block-a">';
                                str += '<p>发布数量：' + data.item[i].sl + '</p>';
                                str += '</div>';
                                str += '<div class="ui-block-b">';
                                str += '<p>抢单数量：' + data.item[i].qdsl + '</p>';
                                str += '</div>';
                                str += '<div class="ui-block-c">';
                                str += '<p>' + data.item[i].createtime + '</p>';
                                str += '</div>';
                                str += '</div>';
                                str += '<div data-role="navbar">';
                                str += '<ul>';
                                str += '<li><a href="#" data-transition="turn" onclick="speed(\'' + data.item[i].docno + '\')">处理进度</a></li>';
                                str += '<li><a href="#" data-transition="turn" onclick="productlist(\'' + data.item[i].docno + '\')">货品详情</a></li>';
                                if (data.item[i].zt == "草稿") {
                                    str += '<li><a href="" data-transition="turn" style="color:white;background-color:cadetblue;" onclick="fabu(' + data.item[i].id + ',0)">' + data.item[i].zt + '</a></li>';
                                }
                                else if (data.item[i].zt == "已发布") {
                                    str += '<li><a href="" data-transition="turn" style="color:white;background-color:crimson;" onclick="fabu(' + data.item[i].id + ',1)">' + data.item[i].zt + '</a></li>';
                                }
                                str += '</ul>';
                                str += '</div>';
                                //str += '<img src="../../images/product_icon.png" />';
                                str += '</li>';
                            }
                           
                        }
                        else {
                            str += '<li>';
                            str += '<h3 style="text-align:center;color:red;" >无数据</h3>';
                            str += '</li>';
                            //提示
                            //layer.open({
                            //    content: "无数据!"
                            //    , skin: 'msg'
                            //    , time: 2 //2秒后自动关闭
                            //});

                        }
                        $("#thelist").html(str);
                        //解决列表样式丢失！
                        $("#thelist").trigger('create');
                        $("#thelist").listview("refresh");
                        layer.close(loginLoadIndex);
                    }
                });
            }
        })
        function fabu(ids, zt) {
            location.href = "sq_edit.html?id=" + ids + "&zt="+zt+"&mobile=" + mobile + "&customerCode=" + customerCode;
        }
        function speed(docnos) {
            location.href = "speed_list.html?docno=" + docnos;
        }
        function productlist(docnos) {
            location.href = "product_list.html?docno=" + docnos;
        }
        //修改
        function update(id) {
            //跳转修改
            location.href = "product_update.html?ids=" + id;
        }


    </script>

</body>
</html>
